package server;

import java.util.Date;

/**
 * Represents a single Auction
 * @author Andreas
 */
public class Auction 
{
	public static int iMaxId=1;
	
	private int iId;
	private Date dEnd;
	private String strDesc;
	private User uHighest;
	private User uOwner;
	private long lPrice;


	/**
	* Constructor
	*/
	public Auction(long lTime, String strDesc, User uOwner) 
	{
		super();
		this.iId = iMaxId++;
		this.dEnd=new Date(System.currentTimeMillis()+lTime*1000);
		this.strDesc = strDesc;
		this.uOwner = uOwner;
	}

	/*
	 * Getters & Setters
	 */
	public int getiId() 
	{
		return iId;
	}
	
	public Date getdEnd()
	{
		return dEnd;
	}

	public String getStrDesc() 
	{
		return strDesc;
	}

	public User getuHighest() 
	{
		return uHighest;
	}

	public void setuHighest(User uHighest) 
	{
		this.uHighest = uHighest;
	}

	public User getuOwner() 
	{
		return uOwner;
	}

	public long getlPrice() 
	{
		return lPrice;
	}

	public void setlPrice(long lPrice) 
	{
		this.lPrice = lPrice;
	}
	
	
	/*
	 * (non-Javadoc) @see java.lang.Object#toString(java.lang.Object)
	 */
	@Override
	public String toString()
	{
		String strHighest="none";
		if(this.uHighest!=null)
		{
			strHighest=uHighest.getStrName();
		}
		AuctionManager am=AuctionManager.getInstance();
		return this.iId+". '"+this.strDesc+"' "+this.uOwner.getStrName()+" "+
		am.formatDate(dEnd)+" "+am.formatLong(lPrice)+" "+strHighest;
	}
}
